int cmp(int* x, int* y)
{
    return *x - *y;
}

int maxProduct(int* nums, int numsSize) {
    qsort(nums, numsSize, sizeof(int), cmp);
    if (nums[0] >= 0 || nums[1] > 0)
    {
        return (nums[numsSize - 1] - 1) * (nums[numsSize - 2] - 1);
    }
    else if (nums[1] <= 0)
    {
        int max1 = (nums[numsSize - 1] - 1) * (nums[numsSize - 2] - 1);
        int max2 = (nums[0] - 1) * (nums[1] - 1);
        int max = max1 > max2 ? max1 : max2;
        return max;
    }
    return 0;
}